import api from '@/utils/api';
import registerServer from '@/utils/register-server';
import request from '@/utils/request';

const {
  link_test,
  save_question,
  get_questions,
  update_answer,
  cluster_run_full,
  cluster_run_range,
  cluster_run_incremental,
  cluster_start_scheduler,
  cluster_stop_scheduler,
  cluster_status,
  cluster_list,
  cluster_top_questions,
} = api;

const methods = {
  get_test: {
    url: link_test,
    method: 'get',
  },
  save_question: {
    url: save_question,
    method: 'post',
  },
  get_question: {
    url: get_questions,
    method: 'post',
  },
  update_answer: {
    url: update_answer,
    method: 'post',
  },
  cluster_run_full: {
    url: cluster_run_full,
    method: 'post',
  },
  cluster_run_range: {
    url: cluster_run_range,
    method: 'post',
  },
  cluster_run_incremental: {
    url: cluster_run_incremental,
    method: 'post',
  },
  cluster_start_scheduler: {
    url: cluster_start_scheduler,
    method: 'post',
  },
  cluster_stop_scheduler: {
    url: cluster_stop_scheduler,
    method: 'post',
  },
  cluster_status: {
    url: cluster_status,
    method: 'get',
  },
  cluster_list: {
    url: cluster_list,
    method: 'post',
  },
  cluster_top_questions: {
    url: cluster_top_questions,
    method: 'post',
  },
} as const;

const trackService = registerServer<keyof typeof methods>(methods, request);

export default trackService;
